package implementor;


import java.sql.Date;




import daoInterface.PurchaseDao;
import dbhandeling.Crude;
import dto.Purchase;

public class PurchaseImp extends Crude implements PurchaseDao
{

String className=new Purchase().getClass().getName();

@Override
public void add(Purchase purchase) throws Exception
{
    insert(purchase);
}
/***********************************************************/

@Override
public void update(Purchase purchase) throws Exception
{
	super.update(className,"balancePaymentId",purchase.getBalancePaymentId()+"","autoPurchaseId",purchase.getautoPurchaseId()+"");
super.update(className,"purchaseDate",purchase.getpurchaseDate()+"","autoPurchaseId",purchase.getautoPurchaseId()+"");
super.update(className,"sellerId",purchase.getsellerId()+"","autoPurchaseId",purchase.getautoPurchaseId()+"");
super.update(className,"taxCode",purchase.gettaxCode()+"","autoPurchaseId",purchase.getautoPurchaseId()+"");
}
/***********************************************************/

@Override
public void delete(Purchase purchase) throws Exception
{
super.delete(className,"autoPurchaseId",purchase.getautoPurchaseId()+"");
}
/***********************************************************/

@Override
public Purchase retrieve(String conditionField,String conditionValue) throws Exception
{
Purchase purchase=(Purchase) super.retreive(className,conditionField,conditionValue);
return purchase;
}
/***********************************************************/

@Override
public Purchase[] retrieveArray(String conditionField,String conditionValue) throws Exception
{
Purchase[] purchase;
Object[] obj=super.retreiveArrayOnCondition(className,conditionField, conditionValue);
purchase=new Purchase[obj.length];
for(int i=0;i<purchase.length;i++)
{
purchase[i]=(Purchase) obj[i];
}
return purchase;
}
/***********************************************************/

@Override
public Purchase[] retrieveAll() throws Exception
{
Purchase[] purchase;
Object[] obj=super.retreiveAll(className);
purchase=new Purchase[obj.length];
for(int i=0;i<purchase.length;i++)
{
purchase[i]=(Purchase) obj[i];
}
return purchase;
}
/***********************************************************/
public int getAutoGenratedKey()
{
	 int key=super.getAutoGenratedKey(className,"autoPurchaseId") ;
	 return key;
}

}

